(setq load-path (cons (concat *init-home-dir* "org-mode/org/lisp/") load-path))
(setq load-path (cons (concat *init-home-dir* "org-mode/org/contrib/lisp/") load-path))



(require 'org-install)
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)

(setq org-agenda-files (list "~/__Gloo/__Admin/"))

(defun organise ()
  (interactive)
  (find-file "~/__Gloo/__Admin/GLOO.org"))

;;
;; Resume clocking tasks when emacs is restarted
;(org-clock-persistence-insinuate)
;;
;; Yes it's long... but more is better ;)
(setq org-clock-history-length 28)
;; Resume clocking task on clock-in if the clock is open
(setq org-clock-in-resume t)
;; Change task state to STARTED when clocking in
(setq org-clock-in-switch-to-state "TODO")
;; Separate drawers for clocking and logs
(setq org-drawers (quote ("PROPERTIES" "LOGBOOK" "CLOCK")))
;; Save clock data in the CLOCK drawer and state changes and notes in the LOGBOOK drawer
(setq org-clock-into-drawer "CLOCK")
;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
(setq org-clock-out-remove-zero-time-clocks t)
;; Don't clock out when moving task to a done state
(setq org-clock-out-when-done nil)
;; Save the running clock and all clock history when exiting Emacs, load it on startup
(setq org-clock-persist (quote history))
;; Disable auto clock resolution
(setq org-clock-auto-clock-resolution nil)

(setq org-export-html-auto-postamble 'nil)
(setq org-export-with-sub-superscripts 'nil)

(setq org-hide "white")

;for the number of levels deep to go (assigning numbers to points)
(setq org-export-headline-levels 5)

(setq org-default-notes-file "~/__Gloo/__Admin/refile.org")

;; I use C-M-r to start capture mode
(global-set-key (kbd "C-M-r") 'org-capture)

;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
(setq org-capture-templates (quote (("t" "todo" entry (file "~/__Gloo/__Admin/refile.org") "* TODO %?
%U
%a" :clock-in t :clock-resume t)
                                    ("n" "note" entry (file "~/__Gloo/__Admin/refile.org") "* %?                                                                            :NOTE:
%U
%a
:CLOCK:
:END:" :clock-in t :clock-resume t)
                                    ("a" "appointment" entry (file+datetree "~/__Gloo/__Admin/diary.org") "* %?
%U" :clock-in t :clock-resume t)
                                    ("p" "Phone call" entry (file "~/__Gloo/__Admin/refile.org") "* Phone %(bh/phone-call) - %(gjg/bbdb-company) :PHONE:\n%U\n\n%?" :clock-in t :clock-resume t)
                                    ("w" "org-protocol" entry (file "~/__Gloo/__Admin/refile.org") "* TODO Review %c
%U" :immediate-finish t :clock-in t :clock-resume t))))


; Use IDO for target completion
(setq org-completion-use-ido t)

; Targets include this file and any file contributing to the agenda - up to 5 levels deep
(setq org-refile-targets (quote ((org-agenda-files :maxlevel . 5) (nil :maxlevel . 5))))

; Targets start with the file name - allows creating level 1 tasks
(setq org-refile-use-outline-path (quote file))

; Targets complete in steps so we start with filename, TAB shows the next level of targets etc
(setq org-outline-path-complete-in-steps t)

; Allow refile to create parent tasks with confirmation
(setq org-refile-allow-creating-parent-nodes (quote confirm))

; Use IDO only for buffers
; set ido-mode to buffer and ido-everywhere to t via the customize interface
; '(ido-mode (quote both) nil (ido))
; '(ido-everywhere t)
